package com.shitu.base.net.service;

import com.alibaba.fastjson.JSON;
import com.shitu.base.net.API;
import com.shitu.base.net.request.RequestHelper;

import java.util.HashMap;
import java.util.Map;

import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;

public class ProviderService {

    public static Request getHomePageRecommend() {
        String url = API.BASE_URL + "provider/getHomePageRecommend";
        Map body = RequestHelper.getBase();
        Map<String, String> map = new HashMap<>();
        map.put("lat", "39.940387");
        map.put("lng", "116.443363");
        body.put("params", map);

        String bodyStr = JSON.toJSONString(body);
        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), bodyStr);
        Request request = new Request.Builder().post(requestBody).url(url).build();
        return request;
    }

    public static Request getHomePageTab(int id, int page) {
        String url = API.BASE_URL + "provider/getHomePageTab";
        Map body = RequestHelper.getBase();
        Map<String, Object> map = new HashMap<>();
        map.put("categoryId", id);
        map.put("page", page);
        map.put("lat", "39.940387");
        map.put("lng", "116.443363");
        body.put("params", map);

        String bodyStr = JSON.toJSONString(body);
        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), bodyStr);
        Request request = new Request.Builder().post(requestBody).url(url).build();
        return request;
    }

    public static Request getHomePageRecommendChange(String currentIds) {
        String url = API.BASE_URL + "provider/getHomePageRecommendChange";
        Map body = RequestHelper.getBase();
        Map<String, Object> map = new HashMap<>();
        map.put("currentIds", currentIds);
        map.put("lat", "39.940387");
        map.put("lng", "116.443363");
        body.put("params", map);

        String bodyStr = JSON.toJSONString(body);
        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), bodyStr);
        Request request = new Request.Builder().post(requestBody).url(url).build();
        return request;
    }

}
